package com.xyoto.community.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.xyoto.community.constant.FollowStatus;
import com.xyoto.community.constant.LoveStatus;
import com.xyoto.community.entity.picture.DynamicPicture;
import com.xyoto.community.po.DynamicPicturePO;
import com.xyoto.community.po.UserTitlePO;
import com.xyoto.community.utils.PictureUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * 动态详情VO
 */
@Data
@ApiModel("动态详情VO")
public class DynamicDetailVo {

    @ApiModelProperty("动态id")
    private Integer id;

    @ApiModelProperty("话题id")
    private Integer topicId;

    @ApiModelProperty("话题名称")
    private String title;

    public void setTopicId(Integer topicId) {
        this.topicId = topicId == null ? 0 : topicId;
    }

    @ApiModelProperty("用户id")
    private Integer userId;

    @ApiModelProperty("头像链接")
    private String avatarUrl;

    @ApiModelProperty("昵称")
    private String nickname;

    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("动态内容")
    private String content;

    @ApiModelProperty("动态图片组")
    private List<DynamicPicturePO> dynamicPicturePo;

    @ApiModelProperty("转发数目")
    private Integer dynamicForwardCount;

    @ApiModelProperty("评论数目")
    private Integer dynamicCommentCount;

    @ApiModelProperty("点赞数目")
    private Integer  dynamicLoveCount;

    @ApiModelProperty("登录用户是否点赞")
    private Short loveStatus;

    @ApiModelProperty("匿名昵称")
    private String anonymousName;

    @ApiModelProperty("匿名头像地址")
    private String anonymousAvatarUrl;

    @ApiModelProperty("动态匿名状态")
    private Integer status;

    @ApiModelProperty("头衔")
    @JsonProperty("userTitle")
    private UserTitlePO userTitlePO;

    public void setStatus(Integer status) {
        this.status = status == null ? 1: status;
    }

    public void setLoveStatus(Short loveStatus) {
        this.loveStatus = loveStatus == null ? LoveStatus.UN_LOVE : loveStatus;
    }

    @ApiModelProperty("登录用户是否关注")
    private Short followStatus;

    public void setFollowStatus(Short followStatus) {
        this.followStatus = followStatus == null ? FollowStatus.UN_FOLLOW : followStatus;
    }

    public DynamicDetailVo(Integer dynamicId, Integer userId, Date createTime, String content) {
        this.id = dynamicId;
        this.userId = userId;
        this.createTime = createTime;
        this.content = content;
        this.avatarUrl = "";
        this.nickname = "";
        this.title = "";
        this.loveStatus = 1;
        this.followStatus = 1;
        this.dynamicCommentCount = 0;
        this.dynamicForwardCount = 0;
        this.dynamicLoveCount = 0;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = PictureUtils.addPrefix(avatarUrl);
    }
}
